package cn.lg.soar.system.auth.model;

import cn.lg.soar.common.data.tree.ITreeResult;
import cn.lg.soar.common.util.BeanCopier;
import cn.lg.soar.system.api.enums.OrgTypeEnum;
import cn.lg.soar.system.auth.entity.Menu;
import cn.lg.soar.system.auth.entity.Org;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;

/**
 * 菜单树形数据
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Getter
@Setter
public class OrgTree implements ITreeResult<OrgTree>, Serializable {

    private Long id;

    private OrgTypeEnum type;

    private String name;

    private List<OrgTree> children;

    @Override
    public List<OrgTree> getChildren() {
        return children;
    }

    @Override
    public void setChildren(List<OrgTree> children) {
        this.children = children;
    }

    public OrgTree() {
    }

    public OrgTree(Org org) {
        if (org == null) {
            return;
        }
        this.id = org.getId();
        this.type = org.getType();
        this.name = org.getName();
    }

    public static OrgTree from(Org org) {
        return new OrgTree(org);
    }

}
